package com.example.fw;

import org.openqa.selenium.By;

public class NavigationHelper extends HelperBase {

	public NavigationHelper(ApplicationManager manager) {
		super(manager);
	}

	public void groupsPage() {
		if (!onGroupsPage()) {
			click(By.xpath("//div/div[3]/ul/li/a"));
		}
	}

	public void mainPage() {
		if (!onMainPage()) {
			click(By.xpath("//div//div[3]//ul//li[3]/a"));
		}
	}

	// --------------------------

	private boolean onMainPage() {
		return driver.findElements(By.id("maintable")).size() > 0;
		
	}

	private boolean onGroupsPage() {
		String currentURL = driver.getCurrentUrl();
		driver.findElement(By.name("new"));
		if (driver.getCurrentUrl().contains("/group.php")
				&& driver.findElements(By.name("new")).size() > 0) {
			return true;
		} else {
			return false;
		}
	}

	public NavigationHelper returnGroups() {

		click(By.xpath("//div//div[4]//div/i/a"));
		return this;
	}
}
